/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bbd.crawler.dp;

import bbd.crawler.dp.fwk.ProcessorInterface;
import bbd.crawler.fwk.BaseFactory;

/**
 *
 * @author Amogh
 */
public class DataProcessorFactory extends BaseFactory {

    private static DataProcessorFactory instance = null;

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public static ProcessorInterface getProcessor ( String classname )
    throws ClassNotFoundException,
            InstantiationException,
            IllegalAccessException
    {
        if ( instance == null ) {

            instance = new DataProcessorFactory();
        }

        return instance.getProcessorInstance ( classname );

    } // end function getProcessor

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public static DataProcessorFactory getInstance ()
    {
        if ( instance == null ) {

            instance = new DataProcessorFactory();
        }

        return instance;

    } // end function getInstance

    //--------------------------------------------------------------------------
    //                             INSTANCE METHODS
    //--------------------------------------------------------------------------

    //--------------------------------------------------------------------------
    /** Javadoc here */
    private DataProcessorFactory () {

        bundleBaseName = "bbd.crawler.dp.dp-map";
        basePackage    = "dp.base.package";
        baseMapConfig  = "dp.map.config";

        loadHashMap();

    } // end default constructor

    //--------------------------------------------------------------------------
    /** Javadoc here */
    public ProcessorInterface getProcessorInstance ( String classname )
    throws ClassNotFoundException,
            InstantiationException,
            IllegalAccessException
    {

        return (ProcessorInterface) getInstance ( getMapKey (classname) );

    } // end function getHandlerInstance

    //--------------------------------------------------------------------------
    /** Javadoc here */
    @Override
    public boolean isMappingAvailable ( String rawKey ) {

        return super.isMappingAvailable ( getMapKey (rawKey) );

    } // end function isMappingAvailable
    
} // end class DataProcessorFactory
